﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Configuration;//them vao

public partial class Dangky : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btHuy_Click(object sender, EventArgs e)
    {
        txtHoten.Text = "";
        txtDiaChi.Text = "";
        txtDienThoai.Text = "";
        txtEmail.Text = "";
        txtMk.Text = "";
        txtNhapLaiMK.Text = "";
        txtTenDangNhap.Text = "";
    }
    protected void btDangKy_Click(object sender, EventArgs e)
    {
        try
        {
            //Gán giá tr? cho bi?n 
            String Hoten = txtHoten.Text;
            String Dienthoai = txtDienThoai.Text;
            String Diachi = txtDiaChi.Text;
            String TenDN = txtTenDangNhap.Text;
            String Matkhau = txtMk.Text;
            String Email = txtEmail.Text;

            string StrCnn = ConfigurationManager.ConnectionStrings["COMPUTERConnectionString"].ConnectionString.ToString();
            SqlConnection cnn = new SqlConnection(StrCnn);
            cnn.Open();
            //Th?c thi l?nh nh?p li?u
            string str = "INSERT INTO KHACHHANG(HoTen,GioiTinh,DienThoai,DiaChi,UserName,Pass,Email) VALUES(N'" + Hoten + "'," + rdbGioitinh.SelectedValue + ",'" + Dienthoai + "',N'" + Diachi + "',N'" + TenDN + "',N'" + Matkhau + "',N'" + Email + "')";
            Xulydulieu.ExecuteNonQuery(str);
            Response.Redirect("~/DangNhap.aspx");
        }
        catch
        {
            lbThongBao.Text = "đăng ký Thất bại";
        }
    
    }
}